Supporting Scripting
You are strongly encouraged to provide support for scripting in your parts. Scripting allows customization of your part's user interface. It is likely that most users will experience scripting indirectly, by using documents created from stationery that contains scripts to provide extra functionality to the user. For example, a user might create a new medical form for a patient and be unaware that data validation is performed by a script.Attaching Scripts
You can attach scripts either to your part as a whole or to some portion of its intrinsic content. Scripts might be attached to text fields, menu commands, buttons, checkboxes or radio buttons, pop-up menus, other controls, or even graphic objects or other content items.Any part can have a script property associated with it, as an annotation to its storage unit. The script property contains a value whose type defines it as an OSA script. Through the script, the user or another part can customize the part's behavior.
Support provided by a part for its script might be implemented in different ways. For example, the editor for a button part might provide a user interface to edit the script. In contrast, a HyperCard-like container part might only support attaching existing scripts to embedded parts.
If a part editor supports attaching scripts to its intrinsic content, such scripts are stored within the part's content rather than as a separate script property. In that case, the user interface should be similar to that used for attaching scripts to embedded parts.
Script-Editing Interface
There can be different interfaces for editing a part's script. For example, a part editor may allow access to the script through a Settings dialog box accessed through the Part Info dialog box. In addition, it may implement a menu command that invokes a dialog box for editing the script. Some parts, such as buttons, do not have an active state and therefore cannot have a menu command. In this case, the Settings dialog box is the only recommended option.Some part editors may support editing the scripts attached to their embedded parts. For example, a HyperCard-like container part might have menu commands that provide a user interface for editing the script in an embedded part's script property. The recommended keyboard equivalent for this command is Command-Option-click (as in HyperCard). You can, however, support other keyboard equivalents, such as Option-Double-click.
Dropping Scripts on a Part
You may wish to give your part the ability to accept scripts dropped onto it. For example, if the user drags an OSA script file onto a button part, the button's part editor should highlight the button appropriately to indicate that it can accept a drop. When the user releases the mouse button, the button part editor should copy the contents into the script property.Drag and drop is intended only as an alternative method for attaching scripts. Therefore, you must also provide a primary mechanism that is easily discoverable, such as the use of a Settings dialog box.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help